package com.qinggeng.framework.config.mq.impl;
import com.alibaba.fastjson.JSONObject;
import com.qinggeng.common.exception.CustomException;
import com.qinggeng.framework.config.mq.dto.MessageBulletChatUserAddCartDTO;
import com.qinggeng.framework.config.mq.dto.MessgaeBulletChatGoodsDetailDTO;
import com.qinggeng.framework.config.mq.handle.MessageHandle;
import com.qinggeng.project.api.websocket.service.BulletChatGoodsDetailServiceImpl;
import com.qinggeng.project.api.websocket.service.BulletChatUserAddCartServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class BulletChatGoodDetailHandleImpl implements MessageHandle {

    @Resource
    private BulletChatGoodsDetailServiceImpl bulletChatGoodsDetailService;
    @Override
    public void handle(String msg) {
        System.out.println("解析handle "+msg);
        try {
            MessgaeBulletChatGoodsDetailDTO dto=JSONObject.parseObject(msg, MessgaeBulletChatGoodsDetailDTO.class);
            bulletChatGoodsDetailService.send(dto);
        }catch (Exception e){
            throw  new CustomException("錯誤"+e.getMessage());

        }
    }

}
